package com.agile.java_seetaface.faceregister;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author ChenZhangKun
 * @Date 2020/4/21 15:49
 */
public class Receive implements Runnable {
    // 监听8002端口
    public static ServerSocket serverSocket;
    static {
        try {
            serverSocket = new ServerSocket(8001);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void run() {
        int i=0;
        while (true) {
            try {
                // 监听端口
                Socket accept =serverSocket.accept();
                //
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(accept.getInputStream()));
                String s = bufferedReader.readLine();
                i++;
                System.out.println(s+"   "+i);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
